

#import "AboutProducController.h"
#import "ProductViewCell.h"
#import "UserProtocolViewController.h"

@interface AboutProducController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) UIImageView *productImgView;
@property (nonatomic, strong) UIImageView *productTextView;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *lb_View;

@end

static NSString *productCell = @"productCell";

@implementation AboutProducController

- (UIImageView *)productImgView{
    if (!_productImgView) {
        _productImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"product_img_logo_nor.png"]];
    }
    return _productImgView;
}

- (UIImageView *)productTextView{
    if (!_productTextView) {
        _productTextView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"product_text_logo_nor.png"]];
    }
    return _productTextView;
}

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] init];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        
        [self.tableView registerNib:[UINib nibWithNibName:@"ProductViewCell" bundle:nil] forCellReuseIdentifier:productCell];
    }
    return _tableView;
}

- (UIView *)lb_View{
    if (!_lb_View) {
        _lb_View = [[UIView alloc] init];
        UILabel *lb_qq = [[UILabel alloc] init];
        lb_qq.text = @"用户交流群: 4638375473";
        UILabel *lb_version = [[UILabel alloc] init];
        lb_version.text = @"version: 1.4.0";
        [self.lb_View addSubview:lb_qq];
        [self.lb_View addSubview:lb_version];
        
        [lb_qq mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.lb_View);
            make.top.equalTo(self.lb_View).mas_offset(5);
        }];
        
        [lb_version mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.lb_View);
            make.bottom.equalTo(self.lb_View).mas_offset(5);
        }];
    }
    return _lb_View;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}

- (void)setupUI{
    [self.view addSubview:self.productTextView];
    [self.view addSubview:self.productImgView];
    [self.view addSubview:self.tableView];
    [self.view addSubview:self.lb_View];
    
    [self.productImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(80);
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.view).mas_offset(50+64);
    }];
    
    [self.productTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(50);
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.productImgView.mas_bottom).mas_offset(5);
    }];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.view);
        make.height.mas_equalTo(50);
        make.top.equalTo(self.productTextView.mas_bottom).mas_offset(60);
    }];
    
    [self.lb_View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.view);
        make.bottom.equalTo(self.view).mas_offset(-50);
        make.height.mas_equalTo(80);
    }];
}

#pragma mark - dataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ProductViewCell *cell = [tableView dequeueReusableCellWithIdentifier:productCell forIndexPath:indexPath];
    
    return cell;
}

#pragma mark - delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UserProtocolViewController *userCotroller = [[UserProtocolViewController alloc] init];
    
    userCotroller.title = @"用户协议";
    
    [self.navigationController pushViewController:userCotroller animated:YES];
    
}



@end
